#ifndef _VFX_SMOKE_H_
#define _VFX_SMOKE_H_
#include "ui/ui_sprite.h"
#include "math/counter.h"

namespace vfx
{


class	Smoke
{
public:
					Smoke();
	virtual			~Smoke();
	virtual void	Tick(float dt);
	virtual void	Render(const math::Vec2& Offset, float Scale);
	virtual void	RenderDebug(const math::Vec2& Offset, float Scale);
	virtual void	ResetPos() ;	// override to setup different initial params
	virtual void	Init(const std::string& DataSet) { m_DataSet = DataSet; SetupXFade();};

	void			SetRotating(bool Val) { m_IsRotating = Val; };
	void			SetFadeSpeed(float Min, float Max) { m_FadeTimeMin = Min;  m_FadeTimeMax=Max; };
	void			SetPos(const math::Vec2& P) { m_Pos = P; };
	bool			IsDone() { return m_IsDone; };
	void			SetSizeMult(float f) { m_SizeMult = f; };
	void			SetSetC(int c) { m_SetC = c; };
	void			SetRebirthC(int C) { m_Rebirth = C; };
private:
	void			SetupXFade();
	std::string		m_DataSet;
	math::Counter	m_XFade;
	int				m_SetC;
	float			m_StartTime, m_MaxTime;
	ui::UISprite	m_SpriteFrom, m_SpriteTo;
	math::Vec2		m_BaseSize;
	float			m_SizeMult;
	int				m_LastIndex;
	float			m_ToRot, m_FromRot;
	bool			m_IsRotating;
	float			m_ToRotSpeed, m_FromRotSpeed;
	math::Vec2		m_MoveSpeed;
	float			m_MaxRotSpeed;
	float			m_FadeTimeMin, m_FadeTimeMax;
	int				m_Rebirth;
	math::Vec2		m_Pos, m_Size;
	bool			m_IsDone;
};


class	SmokeGenerator
{
public:
					SmokeGenerator();
	virtual			~SmokeGenerator();
	void			Setup(float GenTime, int	MaxItr, const std::string& BaseName, int MaxImg);	// actual name is BaseName+"_01"
	virtual void	Tick(float dt);
	virtual void	Render(const math::Vec2& Offset, float Scale);
	virtual void	RenderDebug(const math::Vec2& Offset, float Scale){};
	void			SetPos(const math::Vec2& P) { m_Pos = P; };
	virtual Smoke*	CreateSmoke() { return new Smoke; };	// override this if you want your own custom smoke

protected:
	std::vector<Smoke*>		m_Entries;
	std::string		m_Base;
	int				m_Count;
	int				m_IterationC;
	int				m_ImgC;
	math::Counter	m_NextCloud;
	math::Vec2		m_Pos;
};	

}


#endif //_VFX_SMOKE_H_